
/*
 * Copyright 2002-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2012原作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.validation;

import org.springframework.beans.PropertyAccessException;

/**
 * Strategy for processing {@code DataBinder}'s missing field errors,
 * and for translating a {@code PropertyAccessException} to a
 * {@code FieldError}.
 *
 * <p>The error processor is pluggable so you can treat errors differently
 * if you want to. A default implementation is provided for typical needs.
 *
 * <p>Note: As of Spring 2.0, this interface operates on a given BindingResult,
 * to be compatible with any binding strategy (bean property, direct field access, etc).
 * It can still receive a BindException as argument (since a BindException implements
 * the BindingResult interface as well) but no longer operates on it directly.
 *
 * @author Alef Arendsen
 * @author Juergen Hoeller
 * @since 1.2
 * @see DataBinder#setBindingErrorProcessor
 * @see DefaultBindingErrorProcessor
 * @see BindingResult
 * @see BindException
 */
/**
 *处理｛@code DataBinder｝的丢失字段错误的策略，
 *以及用于将｛@code PropertyAccessException｝转换为
 *｛@code FieldError｝。
 *
 *<p>错误处理器是可插拔的，因此您可以以不同的方式处理错误
 *如果你愿意的话。为典型的需求提供了一个默认的实现。
 *
 *＜p＞注意：从Spring 2.0开始，此接口对给定的BindingResult进行操作，
 *与任何绑定策略（bean属性、直接字段访问等）兼容。
 *它仍然可以接收BindException作为参数（因为BindException实现
 *BindingResult接口），但不再直接对其进行操作。
 *
 *@作者Alef Arendsen
 *@作者于尔根·霍勒
 *@自1.2起
 *@参见DataBinder#setBindingErrorProcessor
 *@请参阅DefaultBindingErrorProcessor
 *@请参阅BindingResult
 *@参见BindException
 */
public interface BindingErrorProcessor {

	/**
	 * Apply the missing field error to the given BindException.
	 * <p>Usually, a field error is created for a missing required field.
	 * @param missingField the field that was missing during binding
	 * @param bindingResult the errors object to add the error(s) to.
	 * You can add more than just one error or maybe even ignore it.
	 * The {@code BindingResult} object features convenience utils such as
	 * a {@code resolveMessageCodes} method to resolve an error code.
	 * @see BeanPropertyBindingResult#addError
	 * @see BeanPropertyBindingResult#resolveMessageCodes
	 */
	/**
	 *将缺少的字段错误应用于给定的BindException。
	 *<p>通常，会为缺少的必填字段创建字段错误。
	 *@param missingField绑定过程中丢失的字段
	 *@param bindingResult要向其中添加错误的errors对象。
	 *您可以添加不止一个错误，甚至可以忽略它。
	 *｛@code BindingResult｝对象具有方便实用程序，例如
	 *｛@code resolveMessageCodes｝方法来解析错误代码。
	 *@see BeanProperty绑定结果#addError
	 *@see BeanProperty绑定结果#resolveMessageCodes
	 */
	void processMissingFieldError(String missingField, BindingResult bindingResult);

	/**
	 * Translate the given {@code PropertyAccessException} to an appropriate
	 * error registered on the given {@code Errors} instance.
	 * <p>Note that two error types are available: {@code FieldError} and
	 * {@code ObjectError}. Usually, field errors are created, but in certain
	 * situations one might want to create a global {@code ObjectError} instead.
	 * @param ex the {@code PropertyAccessException} to translate
	 * @param bindingResult the errors object to add the error(s) to.
	 * You can add more than just one error or maybe even ignore it.
	 * The {@code BindingResult} object features convenience utils such as
	 * a {@code resolveMessageCodes} method to resolve an error code.
	 * @see Errors
	 * @see FieldError
	 * @see ObjectError
	 * @see MessageCodesResolver
	 * @see BeanPropertyBindingResult#addError
	 * @see BeanPropertyBindingResult#resolveMessageCodes
	 */
	/**
	 *将给定的｛@code PropertyAccessException｝转换为适当的
	 *在给定的｛@code Errors｝实例上注册了错误。
	 *<p>请注意，有两种错误类型可用：｛@code FieldError｝和
	 *｛@code ObjectError｝。通常会产生字段错误，但在某些情况下
	 *在某些情况下，可能需要创建全局｛@code ObjectError｝。
	 *@param ex要翻译的｛@code PropertyAccessException｝
	 *@param bindingResult要向其中添加错误的errors对象。
	 *您可以添加不止一个错误，甚至可以忽略它。
	 *｛@code BindingResult｝对象具有方便实用程序，例如
	 *｛@code resolveMessageCodes｝方法来解析错误代码。
	 *@查看错误
	 *@参见字段错误
	 *@见ObjectError
	 *@参见消息代码解算器
	 *@see BeanProperty绑定结果#addError
	 *@see BeanProperty绑定结果#resolveMessageCodes
	 */
	void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult);

}
